package Test;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;

public class test extends JFrame{
	// to be copied
	JTextArea textfield1 = new JTextArea(); 
	JTextArea textfield2 = new JTextArea(); 
	JLabel title1 = new JLabel("Input");
	JLabel title2 = new JLabel("Output");
	private File inputFile;
	private int windowSize;

	public static void main(String[] args) {
		new test();
		
	}

	public test() {
	
		// Set up GUI and the event handling
		createGUI();
		
		this.pack();
		this.setVisible(true);
		go();
	}
	
	private void go() {
		textfield2.setText("go for it");

		
	}

	public test(File inputFile, int windowSize){
		this.inputFile = inputFile;
		this.windowSize = windowSize;
	}
	
	
	public void createGUI(){
		
		// test new gui layout
		// set layout manager, and a commom border to use
		setSize(1200,800);
		
		Container content = this.getContentPane();
		content.setLayout(new BorderLayout());
		//content.setLayout(new GridLayout(2, 2));
		Border whiteSpaceBorder = new EmptyBorder(5,5,5,5);
				
		// top box 
		JPanel topBox = new JPanel();
		topBox.setLayout(new GridLayout(1,2));
		topBox.add(title1);
		topBox.add(title2);
		content.add(topBox, BorderLayout.PAGE_START);
		
	
		
		//center box
		JPanel centerBox = new JPanel();
		JScrollPane scrollPane = new JScrollPane(textfield1);

		centerBox.setLayout(new GridLayout(1,2));
		centerBox.add(scrollPane);
		textfield2.setEditable(true);
		centerBox.add(textfield2);
		content.add(centerBox, BorderLayout.CENTER);
		
		

	}	
	
	public void generate(){
		System.out.println("gut gemacht");
	}
	
	public void print(){

		
		String text;
		StringBuffer lesepuffer = new StringBuffer();
		
		try {
			BufferedReader in = new BufferedReader(new FileReader(inputFile));
			
			try {
				while((text = in.readLine()) !=null){
				lesepuffer.append(text +"\n");
				
				text= new String(lesepuffer);
				}
				textfield2.setText(text);
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}